home *** CD-ROM | disk | FTP | other *** search
/ Interactive Media Design Review 1999 / Interactive Media Design Review 1999.iso / pc / Demos / Herois / Codigo.Cst / 00162_Script_BarraSensível Boneco < prev    next >
Text File  |  1999-03-19  |  6KB  |  242 lines

  1. property intPrimeiro 
  2. property intQuantosX, intQuantosY
  3. property ativo, lado
  4. property sprTxt, sprFoto
  5. property sprLettering
  6. property memoria, limitado
  7. property lastPos
  8.  
  9. on getBehaviorDescription
  10.   return "Barra de sensibilidade do boneco"
  11. end
  12.  
  13. on getPropertyDescriptionList
  14.   set p_list = [ ¼
  15.     #intPrimeiro: [ #comment:   "Primeria posiτπo a esquerda da barra",¼
  16.                  #format:   #integer, ¼
  17.                  #default:    0 ],¼
  18.     #intQuantosX: [ #comment:   "Quantas posicoes nessa barra", ¼
  19.                  #format:   #integer, ¼
  20.                  #default:    8 ],¼
  21.     #intQuantosY: [ #comment:   "Quantas posicoes nessa barra", ¼
  22.                  #format:   #integer, ¼
  23.                  #default:    5 ],¼
  24.     #memoria: [ #comment:   "Memoria minima para movimento nao ser limitado", ¼
  25.                  #format:   #integer, ¼
  26.                  #default:    0 ]¼
  27.   ]
  28.   return p_list
  29. end
  30.  
  31. on beginSprite me
  32.   global myMemSize
  33.   if memoria * 1024 * 1024 < myMemSize then
  34.     set limitado = false
  35.   else
  36.     set limitado = true
  37.   end if
  38.   
  39.   set lastPos = 0
  40.   set ativo = false
  41.   set lado = 0 -- Esquerda
  42.   set sprTxt = 12
  43.   set sprLettering = sprTxt + 1
  44.   set sprFoto = sprTxt + 2
  45.   sendSprite(sprIndicador, #desativa)
  46.   
  47.   repeat with i = sprTxt to sprFoto
  48.     set the visibility of sprite i to false
  49.   end repeat
  50.   
  51. end
  52.  
  53. on cleanSprite me
  54.   global gPronde
  55.   if gPronde <> 1000 then
  56.     repeat with i = sprTxt to sprFoto
  57.       set the visibility of sprite i to true
  58.     end repeat
  59.     puppetSprite sprFoto, false
  60.     puppetSprite sprLettering, false
  61.   end if
  62. end
  63.  
  64. -- Chega sprite p/ direita, quando registro esta do lado esquerdo do
  65. -- sprite
  66. on EsquerdaDireita1 sprnum
  67.   set x = the locH of sprite sprnum
  68.   set the locH of sprite sprnum to 640 - x - the width of sprite sprnum
  69.   
  70. end
  71.  
  72. on EsquerdaDireita2 sprnum
  73.   set x = the locH of sprite sprnum
  74.   set the locH of sprite sprnum to 640 - x
  75. end
  76.  
  77. on desativa me
  78.   puppetSound 2, "SomCliqueSimples"
  79.   
  80.   if not ativo then return
  81.   set ativo = false
  82.   repeat with i = sprTxt to sprFoto
  83.     set the visibility of sprite i to false
  84.   end repeat
  85. end
  86.  
  87. on ativa me, n
  88.   set ativo = true
  89.   set gCriador = n 
  90.   
  91.   puppetSound 2, "SomCliqueSimples"
  92.   
  93.   repeat with i = sprTxt to sprFoto
  94.     set the visibility of sprite i to false
  95.   end repeat
  96.   
  97.   sendSprite(120,#comecaAnima)  
  98.   updateStage
  99.   
  100.   puppetSprite sprFoto, true
  101.   set the member of sprite sprFoto to¼
  102.       member (the number of member "CriadoresFotos" + gCriador - 1)
  103.   puppetSprite sprLettering, true
  104.   set the member of sprite sprLettering to¼
  105.       member (the number of member "CriadoresLettering" + gCriador - 1)
  106.   
  107.   sendSprite(120,#idleClaquete)
  108.   
  109.   set l = random(2)
  110.   if (lado <> l) then
  111.     set lado = l
  112.     EsquerdaDireita1 sprTxt
  113.     EsquerdaDireita2 sprFoto
  114.     EsquerdaDireita2 sprLettering
  115.   end if
  116.   
  117.   sendSprite(120,#idleClaquete)
  118.   
  119.   global gTabelaCriadores
  120.   set arqNum = getAt(gTabelaCriadores, gCriador) + 999
  121.   
  122.   -- Empilha na tabela de paginas percorridas
  123.   empilhaArq arqNum
  124.   
  125.   global gSimples
  126.   mSetCriteria(gSimples,"arqNum","=",arqNum)
  127.   mSelect(gSimples)
  128.   if mSelectCount(gSimples) = 0 then
  129.     alert("Ops, nao consegui acessar texto!")
  130.     return
  131.   end if
  132.   sendSprite(120,#idleClaquete)
  133.   
  134.   set mem = the memberNum of member "TextoCriadores"
  135.   set res = mGetMedia(gSimples, "textoPC", "Criadores", mem)
  136.   if res < 0 then
  137.     put "Erro # " & res
  138.     alert("Erro lendo CD")
  139.   end if
  140.   if the locH of sprite sprTxt > 320 then 
  141.     set a = "left"
  142.   else
  143.     set a = "right"
  144.   end if
  145.   set the lineHeight of member "TextoCriadores" to 16  
  146.   set the alignment of member "TextoCriadores" to a
  147.   
  148.   -- Inicializa links
  149.   global gLinks
  150.   global gLinksCount, gLinksTable, gLinksDest, gLinksTitle
  151.   mSetCriteria(gLinks,"arqNum","=",arqNum)
  152.   mSelect(gLinks)
  153.   set gLinksCount = mSelectCount(gLinks)
  154.   set gLinksTable = []
  155.   set gLinksDest = []
  156.   set gLinksTitle = []
  157.   
  158.   if gLinksCount > 0 then
  159.     set links = gLinksCount
  160.     set gLinksCount = 0
  161.     repeat with i = 1 to links
  162.       
  163.       sendSprite(120,#idleClaquete)
  164.       
  165.       -- Le registro de link
  166.       set mNum = mGetField(gLinks, "mediaNum")
  167.       set sNum = mGetField(gLinks, "subtitNum")
  168.       set pNum = mGetField(gLinks, "palNum")
  169.       set destArq = mGetField(gLinks,"destArq")        
  170.       
  171.       -- Coloca registro na tabela
  172.       set tmp = String(mNum) & "," & String(sNum) & "," &¼
  173.                   String(pNum)
  174.       add gLinksTable, tmp
  175.       add gLinksDest, destArq
  176.       mGoNext(gLinks)
  177.       
  178.     end repeat    
  179.   end if
  180.   
  181.   repeat with i = sprTxt + 1 to sprFoto
  182.     set the visibility of sprite i to true
  183.   end repeat
  184.   
  185.   -- Reinicializa com texto novo
  186.   sendSprite 12, #beginSprite
  187.   set the visibility of sprite sprTxt to true
  188.   
  189.   sendSprite(120,#finalizaAnima)
  190.   
  191.   updateStage
  192.   
  193. end
  194.  
  195. on mouseUp me
  196.   global gCriador
  197.   if ativo then
  198.     set lastPos = -1
  199.     go marker(0)
  200.     desativa me
  201.   else
  202.     set frm = marker("Criadores") + lastPos + 1
  203.     if frm <> the frame then
  204.       preLoad frm, frm
  205.       go frame frm
  206.       updateStage
  207.     end if
  208.     
  209.     ativa me, lastPos + 1
  210.   end if
  211. end
  212.  
  213.  
  214. on idleSprite me
  215.   global gCritico
  216.   if gCritico = 0 then
  217.     set spr = the spriteNum of me
  218.     if (rollOver(spr)) then
  219.       put the mouseH - the locH of sprite spr into tmp
  220.       put tmp * intQuantosX / (1 + the width of sprite spr)¼
  221.         into tmp
  222.       put intQuantosX - tmp - 1 into tmp
  223.       put (the mouseV - the locV of sprite spr) * intQuantosY /¼
  224.         (1+the height of sprite spr) * intQuantosX + tmp into tmp
  225.     else
  226.       put -1 into tmp
  227.     end if
  228.     if tmp <> lastPos then
  229.       set lastPos = tmp
  230.       puppetSound 2, "MoveBoneco"
  231.       if limitado then
  232.         global gMustUpdate
  233.         set gMustUpdate = true
  234.         puppetSprite 11, true
  235.         set the member of sprite 11 to member (the number of member "Icones Criadores" + tmp)
  236.       else
  237.         put marker(0) + intPrimeiro + 1 + tmp into tmp
  238.         go frame tmp
  239.       end if
  240.     end if
  241.   end if
  242. end